$(function(){
	/*---------------微信，qq，新浪的特效----------------------*/
	$("#contact li").find("img").hover(function(){
		$(this).animate({
			"opacity":1
		},100)
	},function(){
		$(this).animate({
			"opacity":0.6
		},100)
	})
	
/*---------------判断用户名和密密码----------------------*/
	var rep = /^\w{6,20}$/gi
	$("#username").blur(function(){
		var value = $("#username").val()
		if(value.length ==0){
			$("#middle_span").html("请输入您的登录名").css("color","red");
			$("#username").css("border","1px solid red")
		}else if(value.length<6){
			$("#middle_span").html("请输入大于6位的登录名").css("color","red");
			$("#username").css("border","1px solid red")
		}else if(!rep.test(value)){
			$("#middle_span").html("请输入正确的字符").css("color","red");
			$("#username").css("border","1px solid red")
		}else {
			$("#middle_span").html("").css("color","#999");
			$("#username").css("border","1px solid #999")
		}
	})
	$("#pwd").blur(function(){
		var rep2 = /^\w{6,20}$/gi
		var value = $("#pwd").val()
		if(value.length ==0){
			$("#spacing3").html("请输入您的密码").css("color","red");
			$("#pwd").css("border","1px solid red")
		}else if(!rep2.test(value)){
			$("#spacing3").html("请输入正确的字符").css("color","red");
			$("#pwd").css("border","1px solid red")
		}else {
			$("#spacing3").html("").css("color","#999");
			$("#pwd").css("border","1px solid #999")
		}
		
	})
/*---------------点击保存用户名时----------------------*/	
	
	
/*---------------点击响应事件----------------------*/	
		var name;
		var upass;
		if ($("input[type=checkbox]").is(":checked") == true){
				//	记住了勾选的值
			    $.cookie('name1',$("#username").val(),{path: "/", expires: 7 })
			}
		//将勾选后放进cookie的值取出来
	    $("#username").val( $.cookie('name1'));
		$("#submit").click(function(){
			name = $("#username").val();
			var arrName =  $.cookie('name').split(",");
//			console.log(arrName);
//			console.log(arrName[0]);
//			console.log(arrName[1]);
			if(name == arrName[0]){
				console.log("该用户已注册通过");
				upass = $("#pwd").val();
				if(upass == arrName[1]){
					console.log("密码匹配成功");
			
				

					alert("登录成功，即将为你跳转到主页");
					window.location.href = "index.html";
				}else{
					console.log("error!");
					alert("密码输入错误，请重新输入！");
				}
			}else if($.cookie('name') ==null){
				console.log("该用户名不存在，点击确定将为您跳转到注册页");
				window.location.href = "register3.html";
			}
		})

/*---------------结束标记----------------------*/
})